package cn.pegasus.teamwork.appinterface.controller.all;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import cn.iyizhan.teamwork.base.util.ObjectUtil;
import cn.pegasus.teamwork.advertisement.entity.BussAdvertInfo;
import cn.pegasus.teamwork.advertisement.service.BussAdvertInfoService;
import cn.pegasus.teamwork.appinterface.base.BaseController;
import cn.pegasus.teamwork.appinterface.util.ParameterEunm;
import cn.pegasus.teamwork.appinterface.util.ReturnRsUtils;

/**
 * @ClassName: AppAdverInfoController
 * @Description: 广告控制器
 * @author buyuer
 * @date 2015年12月5日 下午4:05:46
 * 
 */
@RequestMapping("/adv/*")
@Controller
public class AppAdverInfoController extends BaseController {
    private static final Logger LOGGER = LoggerFactory.getLogger(AppAdverInfoController.class);

    @Autowired
    private BussAdvertInfoService advertInfoService;

    /**
     * 
     * @author buyuer
     * @Title: taskAdverLost
     * @Description: 任务列表广告
     */
    @ResponseBody
    @RequestMapping(value = "/ads", method = RequestMethod.POST)
    public Map<String, Object> adverList(HttpServletRequest request, HttpServletResponse respons,
			@RequestParam Map<String, Object> map) {
    	Map<String, Object> resultMap = new HashMap<String, Object>();
    	boolean isNotNull = ObjectUtil.checkObjectFile(new String[] { "advertPosition" }, map);
		if (isNotNull) {
			// 是否为空参数校验
			map.put("advertState", 0);
			List<BussAdvertInfo> newuses = advertInfoService.query(map);
			if (newuses != null && newuses.size() > 0) {
				Map<String, Object> maps = new HashMap<String, Object>();
				maps.put("lis", newuses);
				resultMap = ReturnRsUtils.resultBackString(ParameterEunm.SUCCESSFUL_CODE, maps);
			} else {
				resultMap = ReturnRsUtils.resultBackString(ParameterEunm.ERROR_NULL_RESULT_CODE, null);
			}
		}
		return resultMap;
    }
}
